package com.powerband.apiheartrate.base

import com.powerband.apiheartrate.manager.FBKManagerController
import android.bluetooth.BluetoothDevice

open class FBKApiBaseMethod: FBKRepository {
    var mManagerController: FBKManagerController? = null
    var isConnected: Boolean? = false
        get() = mManagerController?.blueConnected

    val bluetoothDevice: BluetoothDevice?
        get() = mManagerController?.bluetoothDevice
    override fun startScan(timeOut: Long?) {
        mManagerController?.startScan(timeOut)
    }

    override fun stopScan() {
        mManagerController?.stopScan()
    }

    override fun connectBluetooth(bluetoothDevice: BluetoothDevice?, retryTime: Int?) {
        mManagerController?.connectBluetooth(bluetoothDevice, retryTime)
    }

    override fun connectBluetooth(macAddress: String?, retryTime: Int?) {
        mManagerController?.connectBluetooth(macAddress, retryTime)
    }

    override fun disconnectBle() {
        mManagerController?.disconnectBle()
    }

    override fun registerBleListenerReceiver() {
        mManagerController?.registerBleListenerReceiver()
    }

    override fun unregisterBleListenerReceiver() {
        mManagerController?.unregisterBleListenerReceiver()
    }

    override fun toggleNotifyWith(status: Boolean, type: FBKArmBandCmd) {
        mManagerController?.toggleNotifyWith(status,type)
    }

    override fun readDeviceBatteryPower() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.Battery)
    }

    override fun readFirmwareVersion() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.Firmware)
    }

    override fun readHardwareVersion() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.Hardware)
    }

    override fun readSoftwareVersion() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.Software)
    }

    override fun readSystemId() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.SystemId)
    }

    override fun readModelString() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.ModelNum)
    }

    override fun readManufacturerName() {
        mManagerController?.readCharacteristicValueby(FBKArmBandCmd.Manufacture)
    }

    override fun getDeviceSerial() {
        mManagerController?.getDeviceSerial()
    }

    override fun getDeviceStepFrequency() {
        mManagerController?.getDeviceStepFrequency()
    }

    override fun getRealTimeOxygen() {
        mManagerController?.getRealTimeOxygen()
    }

    override fun syncTime() {
        mManagerController?.syncTime()
    }

    override fun setDeviceThreshold(min: Int,max: Int) {
        mManagerController?.setDeviceThreshold(min,max)
    }

    override fun queryBatteryStatus() {
        mManagerController?.queryBatteryStatus()
    }

    override fun queryDeviceMode() {
        mManagerController?.queryDeviceMode()
    }

    override fun switchDevieMode(mode: FBKDeviceMode) {
        mManagerController?.switchDevieMode(mode)
    }

    override fun updateSeq(sportMode: Boolean) {
        mManagerController?.updateSeq(sportMode)
    }

    override fun startOTA(file: ByteArray?) {
       mManagerController?.startOTA(file)
    }

    override fun getSummaryHeartRate(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getSummaryHeartRate(startDateStamp, endDateStamp)
    }
    override fun getSummarySteps(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getSummarySteps(startDateStamp, endDateStamp)
    }
    override fun getSummaryBloodOxygen(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getSummaryBloodOxygen(startDateStamp, endDateStamp)
    }
    override fun getSummaryPressureIndex(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getSummaryPressureIndex(startDateStamp, endDateStamp)
    }
    override fun getSummaryCalorie(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getSummaryCalorieInfo(startDateStamp, endDateStamp)
    }
    override fun getSummarySleep(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getSummarySleep(startDateStamp, endDateStamp)
    }
    override fun getExerciseData(startDateStamp: Long, endDateStamp: Long) {
        mManagerController?.getExerciseData(startDateStamp, endDateStamp)
    }

    override fun getMotionData(pageSize: Int, sportMode:Boolean) {
        mManagerController?.getMotionData(pageSize, sportMode)
    }

    override fun requestCurrentTime() {
        mManagerController?.requestCurrentTime()
    }

    override fun keepSportAlive() {
        mManagerController?.keepSportAlive()
    }

    override fun qureySportModeDetail() {
        mManagerController?.qureySportModeDetail()
    }

    override fun resetFactory() {
        mManagerController?.resetFactory()
    }

    override fun forseSleepOut() {
        mManagerController?.forseSleepOut()
    }

    override fun setDoNotDisturbTime(
        enable: Boolean,
        startHour: Int,
        startMin: Int,
        endHour: Int,
        endMin: Int
    ) {
        mManagerController?.setDoNotDisturbTime(enable,startHour,startMin,endHour,endMin)
    }

    override fun lightSwitch(on: Boolean) {
        mManagerController?.lightSwitch(on)
    }
}